#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e7 + 5;

int n, m;
string a, b;
int z[N], e[N];
void z_func() {
  z[0] = m;
  int C = 0, R = 0;
  rep(i, 1, m - 1) {
    if (i < C + R)
      z[i] = min(C + R - i, z[i - C]);
    else
      z[i] = 0;
    while (i + z[i] < m && b[z[i]] == b[i + z[i]]) z[i]++;
    if (i + z[i] > C + R) C = i, R = z[i];
  }
}
void e_func() {
  int C = -1, R = -1;
  rep(i, 0, n - 1) {
    if (i < C + R)
      e[i] = min(C + R - i, z[i - C]);
    else
      e[i] = 0;
    // b[m] == 0
    while (i + e[i] < n && a[i + e[i]] == b[e[i]]) e[i]++;
    if (i + e[i] > C + R) C = i, R = e[i];
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a >> b;
  n = a.size(), m = b.size();
  z_func(), e_func();
  ll ans = 0;
  rep(i, 0, m - 1) ans ^= 1ll * (i + 1) * (z[i] + 1);
  cout << ans << endl;
  ans = 0;
  rep(i, 0, n - 1) ans ^= 1ll * (i + 1) * (e[i] + 1);
  cout << ans << endl;
  return 0;
}